package my.interview;

import java.util.Scanner;

/**
 * @DESCRIPTION:
 * @USER: shg
 * @DATE: 2022/12/27 22:10
 */
public class HJ33 {
    public static void main(String[] args) {
        // String b = "00001010000000000000001111000001";
        // int i = Integer.parseInt(b, 2);
        // System.out.println(i);
        // System.out.println("-----");
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String str = scanner.nextLine();
            String str1 = scanner.nextLine();
            Integer result = getResult(str);
            String result1 = getResult1(str1);
            System.out.println("result = " + result);
            System.out.println("result1 = " + result1);
        }
    }

    private static String getResult1(String str1) {
        String string = Integer.toBinaryString(Integer.parseInt(str1));
        String temp = "";
        if (string.length() < 32) {
            int x = 32 - string.length();
            StringBuilder zero = new StringBuilder();
            for (int i = 0; i < x; i++) {
                zero.append(0);
            }
            temp += zero + string;
        }else {
            temp += string;
        }
        System.out.println(temp);
        String[] ans = new String[4];
        for(int i=0;i<4;i++){
            String s = temp.substring(8*i,8*i+8);
            s = Integer.toString(Integer.parseInt(s, 2));
            ans[i] = s;
        }
        return String.join(".", ans);
    }


    private static Integer getResult(String str) {
        String[] split = str.split("\\.");
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < split.length; i++) {
            String temp = Integer.toBinaryString(Integer.parseInt(split[i]));
            String string = "";
            if (temp.length() < 8) {
                int x = 8 - temp.length();
                StringBuilder zero = new StringBuilder();
                for (int j = 0; j < x; j++) {
                    zero.append(0);
                }
                string += zero + temp;
            } else {
                string = temp;
            }
            stringBuilder.append(string);
        }
        return Integer.parseInt(stringBuilder.toString(), 2);
    }
}
